<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>

        <form role="form" id="forms" action="{{url('/home/dingdan/list')}}" method="post" enctype="multipart/form-data">

                        <div class="tab-panel tab-panel0">

     
                <div class="province-list select">
                    <option value="" class="form-content">

                   <!--导入插件-->
                    
                        <script type="text/javascript" src="/js/jquery.js"></script>
                        <script type="text/javascript" src="/js/area.js"></script>
                        <script type="text/javascript" src="/js/location.js"></script>

                        <!--层级联动选择框-->
                    <select id="loc_province" class="" name="sheng" style="width:80px;"></select>
                    <select id="loc_city" class="" name="shi" style="width:100px;"></select>
                    <select id="loc_town" class="" name="xian" style="width:120px;"></select>
                    </option>
                </div>
 
                            
                            
                        <button  class="btn btn-primary" type="submit">添加专卖店</button>
                       {{ csrf_field() }}   
        </form>

</div>

    <script type="text/javascript">
    $(document).ready(function() {
        showLocation();
        $('#addresses .attr').each(function(){
            var str = $(this).attr('attr');
            var info = getInfo(str);
            $(this).html(info);
        });

        //定义获取城市信息方法
        function getInfo(str){
            //console.log(str);
            //拆分字符串
            var arr = str.split(',');
            // console.log(arr);    
            var ls  = new Location;
            var l = ls.items;
            // console.log(l['0,1,2']['5']);
            var sheng = l['0'][arr[0]];
            var shi = l['0,'+arr[0]][arr[1]];
            var xian = l['0,'+arr[0]+','+arr[1]][arr[2]];
            // return sheng+shi+xian;
            return [sheng,shi,xian];
        }

        $('#forms').submit(function(){
            var sheng = $('select[name=sheng]').val();
            var shi = $('select[name=shi]').val();
            var xian = $('select[name=xian]').val();
            var s = sheng+','+shi+','+xian;
            var v = getInfo(s);
            // console.log(v);
            for (var i = 0; i < v.length; i++) {
                var inpu = $('<input type="hidden" name="'+i+'" value="'+v[i]+'" />');
                $('#forms').append(inpu);
            };
            // return false;
        })
  
    });

    
    </script>



</body>
</html>